﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 两个数互换_函数
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 3, j = 5;
            f(i, j);
            Console.WriteLine("{0} {1}\n", i, j);
            f(ref i, ref j);
            Console.WriteLine("{0} {1}\n", i, j);
        }
        //值类型传入参数，不能实现两个数值的互换
        public static int f(int a, int b)   
        {
            int t;
            t = a;
            a = b;
            b = t;
            return 0;
        }
        //引用型传入参数，能实现两个数值的互换
        public static int f(ref int a, ref int b)
        {
            int t;
            t = a;
            a = b;
            b = t;
            return 0;
        }
    }

}
